<!---
	Copyright 2010 Edward Trudeau, Jeremy Battle
    This software is freely available under the MIT License: http://www.opensource.org/licenses/mit-license.php
    http://ayc.googlecode.com
    
--->

<!--- <cffile action="read" file="#getDirectoryFromPath(getTemplatePath())#ejt_dat.xml" variable="dat" />
<cfwddx action="wddx2cfml" input="#dat#" output="yoho" /> --->

<!--- <cfsetting showdebugoutput="no" /> --->

<cfif NOT structKeyExists(session, "aFIs") or NOT arrayLen(session.aFIs) OR structKeyExists(url, 'reloadsession')>
	<cfset session.aFIs = request.fiService.getFieldInstructors(orderby="lastname, firstname") />
    <cfset session.currFI = 1 />
	<cfset session.utils = createObject("component", "ayc.cfc.formbuilder.aycFormUtils").init('ayc', request.FS) />
</cfif>

<!--- 
<cfset aFis  = request.fiService.getFieldInstructors(id=1170) /> --->
<cfset session.utils.setFormVals(page=1) />
<cfset aFields = request.FS.getFieldsByPage(Page=1) />
<cfset thisPage = request.PS.getPage(1)>

<!--- <cfdump var="#form#" /><cfdump var="#minimalForm#" /><cfabort />  --->

<cfif structKeyExists(form, "submit")>
	<cfset minimalForm = session.utils.stripFormVals(form) />
    <cfset tmpArray = request.fiService.getFieldInstructors(argumentCollection=minimalForm) />
    <cfif arrayLen(tmpArray)>
		<cfset session.aFIs = tmpArray />
        <cfset session.currFI = 1 />
        <cfset session.msg = "#arrayLen(session.aFIs)# Field Instructor(s) found matching criteria." />
    	<cflocation url="temp2.cfm" addtoken="no" />
    <cfelse>
    	<cfset request.msg = "No Field Instructors found matching criteria.  Please try removing some criteria to widen the search." />
    </cfif>
</cfif>
<cfimport taglib="ayc/Mod/formutils" prefix="fui">
<cfmodule template="/mod/headerFooter.cfm">
<style>
	body, p, div, input, li, td, th, span, b, em {font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:12px; }
	.ctrlHolder { padding: 0.25em; border-bottom: 1px solid #dfdfdf; display:block; }
	.ctrlHolder input:focus{ outline: none; /* Get rid of the 'glow' effect in WebKit, optional */ }
    .ctrlHolder textarea:focus{ outline: none; /* Get rid of the 'glow' effect in WebKit, optional */ }
	
	.ctrlHolder input[type=text],
	.ctrlHolder select,
	.ctrlHolder textarea,
	.ctrlHolder input[type=checkbox] {border:1px solid #900; font-size:.8em; padding:.125em; max-width:20em;}
	
	.ctrlHolder input:focus, .ctrlHolder textarea:focus {background-color:#FFC;}
	
	.ctrlHolder input[type=text], .ctrlHolder textarea {max-width:40em; width:40%;}
	
	.ctrlHolder span.optLabel {display: inline; margin-right:3em;}
	.ctrlHolder div.optionsList {margin-left:50%}
	.ctrlHolder div.optionsList input {display:block;float:left; margin-right:1.5em;}
	.ctrlHolder div.optionsList span.optLabel {display:block;}
	.ctrlHolder div.optionsList input[type=text] {display:inline;}
	
	.ctrlHolder .inlineLabel {display:block; float:left; width:45%; font-weight:bold; text-align:right; margin-right:2em;}
	table.likertTable td  {padding:auto;}
	div.colx {float:left; width:48%; }
	div.coly {float:right; width:48%;}
	div.clr {float:none; clear:both; width:100%; display:block; height:10px; border:none; }
</style>

<h2>Find Field Instructors</h2>
<fui:form pageid=1 action="findFi.cfm">
	<div class="colx">
    <cfloop from="1" to="#arrayLen(aFields)#" index="p">
    <cfif p EQ int(arrayLen(aFields)/2)+1></div><div class="coly"></cfif>
    <fui:field field=#aFields[p]# /><!--- <cfoutput>#aFields[p].getFieldId()#</cfoutput>, ---> 
    </cfloop></div>
    <div class="clr"></div>
</fui:form>
</cfmodule>

